<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<%
    String path = request.getContextPath();
    if (path.equals("/")) {path = "";}
    request.setAttribute("path", path);
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <base href="http://192.168.1.30:8081/XCardServer/">
        <title>金汉弘后台管理---公司员工管理</title>
        <link rel="shortcut icon" type="image/x-icon" href="<%=path%>/favicon.ico" >
        <link href="<%=path %>/css/all.css" rel="stylesheet" type="text/css" />
        <link type="text/css" rel="stylesheet" href="${path}/js/formValidator/style/validator.css" />
        <style type="text/css">
          .require_tip {color:#f11}
        </style>
        <script type="text/javascript" src="${path}/js/jquery/jquery-1.5.1.js"></script>
        <script type="text/javascript" src="${path}/js/formValidator/formValidator.min.js" charset="UTF-8"></script>
        <script type="text/javascript" src="${path}/js/formValidator/formValidatorRegex.js" charset="UTF-8"></script>
        <script type="text/javascript" src="<%=path%>/js/common.js"></script>
        <script type="text/javascript" src="<%=path%>/ckeditor/ckeditor.js"></script>
        <script type="text/javascript">
        $(function() {
        	CKEDITOR.replace('editor1');
        	
            $.formValidator.initConfig(
                {formID:"uploadForm", submitOnce:false,
                onSuccess:function(){
                	return true;},
                onError:function(msg,obj,errorlist){
                    //$.map(errorlist,function(msg1){alert(msg1)});
                    alert(msg);
                }
            });
            $("#name2").formValidator({onShow:"",onFocus:"请输入名片名称",onCorrect:"　"})
                .inputValidator({min:1,onError:"名片名称不能为空"})
                .inputValidator({max:30,onError:"名片名称长度最多为30"});
            
            $("#mobile2").formValidator({onShow:"", onCorrect:"　", onFocus:""})
                .inputValidator({min:11,max:11,onError:"电话号码必须为11位"})
                .regexValidator({regExp: "intege1",dataType:"enum", onError:"电话号码只能输入数字"})
                .ajaxValidator({
                    dataType : "html",
                    async : true,
                    url : "${path}/mgr/company/employee_checkMobile?id=<s:property value='id'/>",
                    success : function(data){
                        if(data == "ok") return true;
                        if (data == "exist") {
                            alert("电话号码已存在");
                            return false;
                        }
                        return false;
                    },
                    buttons: $("#submitForm"),
                    error: function(XMLHttpRequest, textStatus, errorThrown){alert("服务器没有返回数据，可能服务器忙，请重试"+errorThrown);},
                    onError : "电话号码验证未通过",
                    onWait : "正在对电话号码进行验证，请稍候..."
                });
            
            $("#address2").formValidator({onShow:"",onFocus:"请输入名片地址",onCorrect:"　"})
                .inputValidator({min:1, onError:"名片地址不能为空"})
                .inputValidator({max:256, onError:"名片地址长度最多为256"});
            
        });
        
        </script>
    </head>

    <body style="margin: 2, 0, 0, 13">
    
         <div id="right2">
            <div class="title">
                    <div class="floatButton"><input type="button" value="公司员工管理" class="button2" /></div>
                    <div style="background-color: #e6e6e6;">
                    <div class="content">
                        <div class="apply">
                            <div class="title">
                                <b>
                                  <s:if test="id==null">新增公司员工名片
                                  </s:if>
                                  <s:else>编辑公司员工名片
                                  </s:else>
                              </b>
                            </div>
                            <s:if test="hasActionErrors()">
                               <div class="line" style="height: 40px;border: 1px solid #f91;background-color: #ffd;font-style: italic;"><s:actionerror/> </div>
                            </s:if>
                            <div class="text">
                              <s:if test="id==null">
                                  <s:set name="ation" value="#request.path + '/mgr/company/employee_addCmpEmployeeCard'"></s:set>
                              </s:if>
                              <s:else>
                                  <s:set name="ation" value="#request.path + '/mgr/company/employee_updateCmpEmployeeCard'"></s:set>
                              </s:else>
                                <form method="post" id="uploadForm" name="uploadForm" enctype="multipart/form-data" action='${path}/ckeditor/post.jsp'>
                                  <input type="hidden" name="id" value="<s:property value='id'/>" /> 
                                    <table id="tablea" class="tablea">
                                        <tr><td class="left">员工名片名称<span class="require_tip">*</span>：</td><td><input type="text" value="<s:property value='name'/>" maxlength="40" id="name" name="name" class="normaltxt"/></td><td width="220"><div id="nameTip"></div></td></tr>
                                        <tr><td class="left">员工名片电话<span class="require_tip">*</span>：</td><td><input type="text" value="<s:property value='mobile'/>" <s:if test="id!=null">readonly="readonly""</s:if> maxlength="40" id="mobile"  name="mobile" class="normaltxt"/></td><td><div id="mobileTip"></div></td></tr>
                                        <tr><td class="left">员工名片地址<span class="require_tip">*</span>：</td><td><input type="text" value="<s:property value='address'/>" maxlength="40" id="address" name="address" class="normaltxt"/></td><td><div id="addressTip"></div></td></tr>
                                        <tr>
                                            <td class="left">测试<span class="require_tip">*</span>：</td><td>
                                                <textarea rows="" cols="" id="editor1" name="editor1">100</textarea>
                                            </td><td><div id="addressTip"></div></td></tr>
                                        <tr><td class="left"></td><td colspan="2"><input type="submit" value="确定" class="" id="submitForm" /><input type="reset" value="重置" class="" /><input type="button" onclick="history.go(-1)" value="返回" class="" /></td></tr>
                                    </table>
                                    <input type="file" id="uploadfile" name="licensefile"  style="position:relative;right:99999px;" onchange="loadFile()" />
                                </form>
                            </div>
                        </div>
                    </div>
                </div> 
            </div>
             
        </div>
        
    </body>
</html>
